package thread;

public class DaemonThreadDemo {
    public static void main(String[] args) {
       Thread rose = new Thread(){
           public void run(){
               for (int i =0;i<5;i++){
                   System.out.println("rose:let me go!");
                   try {
                       Thread.sleep(1000);
                   } catch (InterruptedException e) {
                   }
               }
               System.out.println("rose:aaaaaaaaaaaaaaaaaaa....");
               System.out.println("rose卒");
           }
       } ;
       Thread jack = new Thread(){
           public void run(){
               while (true){
                   System.out.println("jack:you jump!I jump!");
                   try {
                       Thread.sleep(1000);
                   } catch (InterruptedException e) {
                   }
               }
           }
       };
       rose.start();
       jack.setDaemon(true);
       jack.start();

       //while (true);若主线程还在运行，则哪怕rose线程结束，jack守护线程也不会结束
    }
}
